#version 460

#include "project_matrix.glsl"
#include "gradient_color.glsl"



layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inWeights;
layout(location = 2) in vec2 inNormal;




layout(location = 0) out vec4 vColor;
//layout(location = 1) out flat int GradientNum;
out gl_PerVertex {
	vec4	gl_Position;
	float	gl_PointSize;
};

//vec2 pos[4] = {vec2(10.0, 10.0), vec2(100.0, 10.0), vec2(10.0, 100.0), vec2(100.0, 100.0)};
void main(void){
	//gl_Position = mat_ProjecView * mat_view * mat_Model[gl_InstanceIndex] * vec4(inPos, 0.0, 1.0);
	mat3x2 mat = m_LP_SD[gl_InstanceIndex];
	//gl_Position = vec4(inPos + mat.xy, 0.0, 1.0);
	vec4 v = vec4(0.0, 0.0, 0.0, 1.0);
	v.xy = (inPos.xy * mat[2].x) + (mat[1] * inWeights.xy);
	//v.xy = inPos;
	//v.xy = inColor.xy;
	v.xy += mat[0];
	v.xy *= m_Scale;
	v.xy += m_Loc;
	
	v.z = mat[2].y;

	gl_Position = mat_ProjecView * v;
	
	vColor = f_buildColor(InstanceColor[gl_InstanceIndex].x);
	
	gl_PointSize = 4.0;
}



